<template>
	<view class="content">
		<image src="../../static/mine/blue-bg.png" mode="widthFix" class="bg-img"></image>
		<CustomNav :topBgColor="topBgColor" :color="titleColor" :backColor="'#999'" :isBack="true" :custom="custom"
			:title="'我的随手拍'"></CustomNav>
		<view class="title-item">
			<view class="tab-item" :class="tabActive==9?'active':''" @click="bindActive(9)">全部</view>
			<view class="tab-item" :class="tabActive==0?'active':''" @click="bindActive(0)">待处理</view>
			<view class="tab-item" :class="tabActive==1?'active':''" @click="bindActive(1)">已受理</view>
			<!-- <view class="tab-item" :class="tabActive==2?'active':''" @click="bindActive(2)">驳回</view> -->
			<view class="tab-item" :class="tabActive==3?'active':''" @click="bindActive(3)">结案</view>
		</view>
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="clap-block" v-for="(item,index) in list" :key="item.id"
					@click="navigate('/page_other/look/detail?id='+item.id)">
					<view style="display: flex; flex-direction: row;padding: 30rpx;">
						<image :src="item.faceUrl"
							style="width: 80rpx;height: 80rpx; border-radius: 50%; background-color: #f5f5f5;margin-right: 30rpx;">
						</image>
						<view class="info-list">
							<view class="name">{{item.userName}}</view>
							<view class="text">{{item.content}}</view>
							<view class="img-list">
								<image :src="item1" v-for="(item1,index1) in item.picList" :key="index1"
									class="img-item" mode="aspectFill">
								</image>
							</view>
							<view class="address-item">
								<image src="../../static/look/position.png" class="iconfont"></image>
								<view class="address">{{item.address}}</view>
							</view>
							<view class="info-item">
								<view class="time-item">
									<image src="../../static/look/time.png" class="iconfont"></image>
									<view class="time">{{item.crtTimeText}}</view>
								</view>
								<view class="state" v-if="item.status==0">待处理</view>
								<view class="state1" v-else-if="item.status==3">结案</view>
								<view class="state3" v-else>已受理</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<view v-else-if="list.length==0&&!listConf.more" style="text-align: center;">暂无数据</view>
			<view v-if="list.length>0&&!listConf.more" style="text-align: center;">没有更多了</view>
		</view>
	</view>
</template>

<script>
	import {
		getCustomNavData,
		isMore
	} from '@/util/util.js'
	import {
		getPageFormList
	} from '@/api/look.js';
	import {
		getStorage
	} from '@/util/auth';
	export default {
		data() {
			return {
				custom: null,
				topBgColor: 'rgba(0,0,0,0)',
				titleColor: '#fff',
				tabActive: 9,
				list: [],
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				}
			}
		},
		onPageScroll(e) {
			if (e.scrollTop >= 50) {
				this.topBgColor = '#117DFF';
			} else {
				this.topBgColor = 'rgba(0,0,0,0)';
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			bindActive(index) {
				this.tabActive = index
				this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getPageFormList({
					page: this.listConf.page,
					limit: this.listConf.limit,
					status: this.tabActive,
					userId: getStorage('login').id
				}).then(data => {
					uni.hideLoading()
					let list = data.list || [];
					list.forEach((item, index) => {
						if (list[index].picList && list[index].picList.length > 0) {
							list[index].picList = list[index].picList[0].url.split(',');
							list[index].picList = list[index].picList.splice(0, 2)
						}
					})
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.listConf.more = isMore(this.listConf.page, this.listConf.limit, data.count);
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onReachBottom() {
			if (this.listConf.more) {
				this.listConf.page++;
				this.getList()
			}
		},
		onLoad() {
			this.custom = getCustomNavData();
			this.getList(true)
		}
	}
</script>

<style lang="scss">
	page {
		background: #F5F5F5;
	}

	.content {
		background: #F5F5F5;
		width: 100%;


		.bg-img {
			width: 100%;
			//position: relative;
		}

		.title-item {
			width: 100%;
			display: flex;
			flex-direction: row;
			margin-top: -440rpx;
			justify-content: space-around;

			.tab-item {
				position: relative;
				display: flex;
				justify-content: center;
				flex-direction: row;
				align-items: center;
				flex: none;
				font-size: 30rpx;
				height: 80rpx;
				padding: 0 20rpx;
				color: #fff;
			}

			.tab-item.active {
				border-bottom: 2px solid #fff;
				color: #fff;
				font-size: 34rpx;
			}
		}

		.info-block {
			min-height: 60vh;
			display: flex;
			flex-direction: column;
			background: #F5F5F5;
			margin-top: 30rpx;
			border-radius: 60rpx;
			height: auto;
			position: relative;
			padding: 30rpx;

			.clap-block {
				width: 100%;
				height: auto;
				background: #fff;
				box-shadow: 0 0 10px 0 #dedede;
				border-radius: 20rpx;
				margin-bottom: 30rpx;


				.info-list {
					width: calc(100% - 120rpx);
					display: flex;
					flex-direction: column;
					font-size: 34rpx;
					//padding: 30rpx;

					.name {
						color: #027BFD;
						margin-bottom: 10rpx;
						font-weight: 600;
					}

					.text {
						font-size: 28rpx;
						font-weight: 500;
						word-break: keep-all;
						word-wrap: break-word;
						white-space: pre-line;
					}

					.img-list {
						display: flex;
						flex-direction: row;
						margin-top: 30rpx;
						flex-wrap: wrap;

						.img-item {
							width: calc((100% - 20rpx)/2);
							height: 250rpx;
							margin-right: 20rpx;
							border-radius: 20rpx;
							margin-bottom: 20rpx;
						}

						.img-item:last-child {
							margin-right: 0;
						}
					}

					.address-item {
						width: 100%;
						margin-top: 30rpx;
						display: flex;
						flex-direction: row;
						align-items: center;

						.iconfont {
							width: 28rpx;
							height: 35rpx;
							margin-right: 20rpx;
						}

						.address {
							width: calc(100% - 60rpx);
							color: #027BFD;
							font-size: 28rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}
					}

					.info-item {
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						margin-top: 30rpx;

						.time-item {
							color: #999;
							display: flex;
							flex-direction: row;
							align-items: center;

							.iconfont {
								width: 30rpx;
								height: 30rpx;
								margin-right: 20rpx;
							}

							.time {
								font-size: 28rpx;
							}
						}

						.state {
							color: #027BFD;
							font-size: 28rpx;
						}

						.state1 {
							color: #47A244;
							font-size: 28rpx;
						}

						.state2 {
							color: #D7080A;
							font-size: 28rpx;
						}

						.state3 {
							color: #FE7526;
							font-size: 28rpx;
						}
					}
				}
			}
		}
	}
</style>